package top.xchch.creational.factory.simplefactory;

/**
 * 简单工厂类
 */
public class SimpleFactory {
    public BasePizza createPizza(String orderType) {
        System.out.println("使用简单工厂模式");

        BasePizza pizza = null;
        if ("greek".equals(orderType)) {
            pizza = new GreekPizza();
            pizza.setName("希腊披萨");
        } else if ("cheese".equals(orderType)) {
            pizza = new CheesePizza();
            pizza.setName("奶酪披萨");
        } else if ("pepper".equals(orderType)) {
            pizza = new PepperPizza();
            pizza.setName("胡椒披萨");
        } else {
            throw new RuntimeException("没有这个类型的 pizza !!!");
        }

        pizza.prepare();
        pizza.bake();
        pizza.cut();
        pizza.box();

        return pizza;
    }
}
